{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ae4e2e47",
   "metadata": {},
   "source": [
    "---------\n",
    "* 日期：2022-10-19 | week09 \n",
    "* 课程：Python\n",
    "* 记录人：杨静雯~\n",
    "---------\n",
    "\n",
    "# 本周学习目标\n",
    "\n",
    "> 1.列表的方法\n",
    "> 2.while循环\n",
    "\n",
    " 1. 列表的方法\n",
    "> 1.使用.Tab键查看列表的方法\n",
    "\n",
    "> 2.使用help（查看方法的使用规则）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5ec4956c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'jalynn', 'jane']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = [\"jack\",\"alex\",\"jalynn\",\"jane\"] \n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d26af51f",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 1.1 列表的增加"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4fa89d36",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"liushizhen\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "15e03467",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'jalynn', 'jane', 'liushizhen']"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "bbb62056",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "1efc515a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function insert:\n",
      "\n",
      "insert(index, object, /) method of builtins.list instance\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "038fc696",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'jalynn', 'jane', 'liushizhen']"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e59f4580",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.insert(2,\"ohhh\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "2b2b9cfe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'ohhh', 'ohhh', 'jalynn', 'jane', 'liushizhen']"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "695532ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "### 2.列表的删除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "3a885a56",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(value, /) method of builtins.list instance\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "482c10f5",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.remove(\"ohhh\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "56d91a4c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'jalynn', 'jane', 'liushizhen']"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e3bd4389",
   "metadata": {},
   "outputs": [],
   "source": [
    "* 正确的删除方法的流程图\n",
    "> 1.查询 value是否存在列表当中  (可以用in来查询)\n",
    "> 2.对存在的value进行删除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "7bb19b05",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"Yang\" in names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "797be328",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "list.remove(x): x not in list",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [18]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mnames\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mremove\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mYang\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
      "\u001b[1;31mValueError\u001b[0m: list.remove(x): x not in list"
     ]
    }
   ],
   "source": [
    "names.remove(\"Yang\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "a1eb6888",
   "metadata": {},
   "outputs": [],
   "source": [
    "if \"Yang\" in names:\n",
    "    names.remove(\"Yang\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fdbd3619",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践：删除系统：\n",
    "1. 如果输入的值存在，删除；\n",
    "2. 如果输入的结果不存在，提示用户查询无结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "a3965310",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'jalynn', 'jane', 'liushizhen']"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "72ef4c6a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入要删除的内容：alex\n",
      "您输入的结果不存在，删除无效\n",
      "['jack', 'jane', 'liushizhen']\n"
     ]
    }
   ],
   "source": [
    "user_input_name = input(\"请输入要删除的内容：\")\n",
    "if user_input_name in names:\n",
    "   names.remove(user_input_name)\n",
    "else:\n",
    "    print(\"您输入的结果不存在，删除无效\")\n",
    "print(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "f93b4406",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入要删除的内容：jack\n",
      "删除成功\n",
      "['jane', 'liushizhen']\n"
     ]
    }
   ],
   "source": [
    "user_input_name = input(\"请输入要删除的内容：\")\n",
    "if user_input_name in names:\n",
    "    names.remove(user_input_name)\n",
    "    print(\"删除成功\")\n",
    "else:\n",
    "    print(\"您输入的结果不存在，删除无效\")\n",
    "print(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "da3cc352",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jane', 'liushizhen']"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "248600a3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 重新创建names列表数据\n",
    "names = [\"jack\",\"alex\",\"jalynn\",\"jane\"] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "4d001b70",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'jalynn', 'jane']"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "1ec59ca7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(value, /) method of builtins.list instance\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "06f56e4c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function pop:\n",
      "\n",
      "pop(index=-1, /) method of builtins.list instance\n",
      "    Remove and return item at index (default last).\n",
      "    \n",
      "    Raises IndexError if list is empty or index is out of range.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.pop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "b623ca9c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'jane'"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.pop() # 直接使用pop()，则删除最后一位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "76d28704",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'jalynn']"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "3ac36f9e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'jalynn'"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.pop(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "d12b141c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex']"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "c71b57cc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "34a23412",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入删除的索引值：1\n"
     ]
    }
   ],
   "source": [
    "pop_index = int(input (\"输入删除的索引值：\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "60e77e61",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "删除成功\n"
     ]
    }
   ],
   "source": [
    "if pop_index<len(names):\n",
    "    names.pop(pop_index)\n",
    "    print(\"删除成功\")\n",
    "else:\n",
    "    print(\"您输入的值不在index的范围内\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "b7aac0bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack']"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "acca418c",
   "metadata": {},
   "outputs": [],
   "source": [
    "### 3.列表的修改"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "3a1f065d",
   "metadata": {},
   "outputs": [],
   "source": [
    "names[0] = \"liushizhen\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "d7ffd5bf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['liushizhen']"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a8ea981b",
   "metadata": {},
   "outputs": [],
   "source": [
    "### 4.列表的其他方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "46c33764",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = [\"jack\",\"alex\",\"jalynn\",\"jane\"] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "9565aaa9",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "3bf6f1a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "b1b8a936",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = [\"jack\",\"alex\",\"jalynn\",\"jane\"] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "id": "6bd3dd14",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'jalynn', 'jane']"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "id": "261d20ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function extend:\n",
      "\n",
      "extend(iterable, /) method of builtins.list instance\n",
      "    Extend list by appending elements from the iterable.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.extend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "4c96f178",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['刘石珍', '刘慧琳', '赵子钰']"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names_class2 = [\"刘石珍\",\"刘慧琳\",\"赵子钰\",]\n",
    "names_class2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "id": "45d19ad8",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'names_class1' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [127]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mnames_class1\u001b[49m\u001b[38;5;241m.\u001b[39mextend(names_class2)\n",
      "\u001b[1;31mNameError\u001b[0m: name 'names_class1' is not defined"
     ]
    }
   ],
   "source": [
    "names_class1.extend(names_class2) # 注意：使用列表的方法的列表进行扩展"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "360eef92",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'names_class1' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [123]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mnames_class1\u001b[49m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'names_class1' is not defined"
     ]
    }
   ],
   "source": [
    "names_class1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "d7ef768d",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (291313769.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [110]\u001b[1;36m\u001b[0m\n\u001b[1;33m    ---------\u001b[0m\n\u001b[1;37m             ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "---------\n",
    "* sort 排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "72f43ad2",
   "metadata": {},
   "outputs": [],
   "source": [
    "立定跳远_男生 = [230,250,245,279,255,260,265,270,288]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "8bf6bc77",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sort:\n",
      "\n",
      "sort(*, key=None, reverse=False) method of builtins.list instance\n",
      "    Sort the list in ascending order and return None.\n",
      "    \n",
      "    The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n",
      "    order of two equal elements is maintained).\n",
      "    \n",
      "    If a key function is given, apply it once to each list item and sort them,\n",
      "    ascending or descending, according to their function values.\n",
      "    \n",
      "    The reverse flag can be set to sort in descending order.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(立定跳远_男生.sort)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "64cb76fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "立定跳远_男生.sort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "bc7b4e7a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[230, 245, 250, 255, 260, 265, 270, 279, 288]"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "立定跳远_男生"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "bf0d59d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "立定跳远_男生.sort(reverse = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "id": "e81f079f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[288, 279, 270, 265, 260, 255, 250, 245, 230]"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "立定跳远_男生"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "da70f5ef",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "1cd18646",
   "metadata": {},
   "source": [
    "# 2.while循环\n",
    "\n",
    "* while True 是循环概念中非常重要的一种方式，他可以实现for循环的指定次数，也可以在特定条件下停止"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "id": "4ac8b431",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "外界有很多反对我爱你的声音...... 0\n",
      "外界有很多反对我爱你的声音...... 1\n",
      "外界有很多反对我爱你的声音...... 2\n",
      "外界有很多反对我爱你的声音...... 3\n",
      "外界有很多反对我爱你的声音...... 4\n",
      "外界有很多反对我爱你的声音...... 5\n",
      "外界有很多反对我爱你的声音...... 6\n",
      "外界有很多反对我爱你的声音...... 7\n",
      "外界有很多反对我爱你的声音...... 8\n",
      "外界有很多反对我爱你的声音...... 9\n",
      "外界有很多反对我爱你的声音...... 10\n",
      "外界有很多反对我爱你的声音...... 11\n",
      "外界有很多反对我爱你的声音...... 12\n",
      "外界有很多反对我爱你的声音...... 13\n",
      "外界有很多反对我爱你的声音...... 14\n",
      "外界有很多反对我爱你的声音...... 15\n",
      "外界有很多反对我爱你的声音...... 16\n",
      "外界有很多反对我爱你的声音...... 17\n",
      "外界有很多反对我爱你的声音...... 18\n",
      "外界有很多反对我爱你的声音...... 19\n",
      "外界有很多反对我爱你的声音...... 20\n",
      "外界有很多反对我爱你的声音...... 21\n",
      "外界有很多反对我爱你的声音...... 22\n",
      "外界有很多反对我爱你的声音...... 23\n",
      "外界有很多反对我爱你的声音...... 24\n",
      "外界有很多反对我爱你的声音...... 25\n",
      "外界有很多反对我爱你的声音...... 26\n",
      "外界有很多反对我爱你的声音...... 27\n",
      "外界有很多反对我爱你的声音...... 28\n",
      "外界有很多反对我爱你的声音...... 29\n",
      "外界有很多反对我爱你的声音...... 30\n",
      "外界有很多反对我爱你的声音...... 31\n",
      "外界有很多反对我爱你的声音...... 32\n",
      "外界有很多反对我爱你的声音...... 33\n",
      "外界有很多反对我爱你的声音...... 34\n",
      "外界有很多反对我爱你的声音...... 35\n",
      "外界有很多反对我爱你的声音...... 36\n",
      "外界有很多反对我爱你的声音...... 37\n",
      "外界有很多反对我爱你的声音...... 38\n",
      "外界有很多反对我爱你的声音...... 39\n",
      "外界有很多反对我爱你的声音...... 40\n",
      "外界有很多反对我爱你的声音...... 41\n",
      "外界有很多反对我爱你的声音...... 42\n",
      "外界有很多反对我爱你的声音...... 43\n",
      "外界有很多反对我爱你的声音...... 44\n",
      "外界有很多反对我爱你的声音...... 45\n",
      "外界有很多反对我爱你的声音...... 46\n",
      "外界有很多反对我爱你的声音...... 47\n",
      "外界有很多反对我爱你的声音...... 48\n",
      "外界有很多反对我爱你的声音...... 49\n",
      "外界有很多反对我爱你的声音...... 50\n",
      "外界有很多反对我爱你的声音...... 51\n",
      "外界有很多反对我爱你的声音...... 52\n",
      "外界有很多反对我爱你的声音...... 53\n",
      "外界有很多反对我爱你的声音...... 54\n",
      "外界有很多反对我爱你的声音...... 55\n",
      "外界有很多反对我爱你的声音...... 56\n",
      "外界有很多反对我爱你的声音...... 57\n",
      "外界有很多反对我爱你的声音...... 58\n",
      "外界有很多反对我爱你的声音...... 59\n",
      "外界有很多反对我爱你的声音...... 60\n",
      "外界有很多反对我爱你的声音...... 61\n",
      "外界有很多反对我爱你的声音...... 62\n",
      "外界有很多反对我爱你的声音...... 63\n",
      "外界有很多反对我爱你的声音...... 64\n",
      "外界有很多反对我爱你的声音...... 65\n",
      "外界有很多反对我爱你的声音...... 66\n",
      "外界有很多反对我爱你的声音...... 67\n",
      "外界有很多反对我爱你的声音...... 68\n",
      "外界有很多反对我爱你的声音...... 69\n",
      "外界有很多反对我爱你的声音...... 70\n",
      "外界有很多反对我爱你的声音...... 71\n",
      "外界有很多反对我爱你的声音...... 72\n",
      "外界有很多反对我爱你的声音...... 73\n",
      "外界有很多反对我爱你的声音...... 74\n",
      "外界有很多反对我爱你的声音...... 75\n",
      "外界有很多反对我爱你的声音...... 76\n",
      "外界有很多反对我爱你的声音...... 77\n",
      "外界有很多反对我爱你的声音...... 78\n",
      "外界有很多反对我爱你的声音...... 79\n",
      "外界有很多反对我爱你的声音...... 80\n",
      "外界有很多反对我爱你的声音...... 81\n",
      "外界有很多反对我爱你的声音...... 82\n",
      "外界有很多反对我爱你的声音...... 83\n",
      "外界有很多反对我爱你的声音...... 84\n",
      "外界有很多反对我爱你的声音...... 85\n",
      "外界有很多反对我爱你的声音...... 86\n",
      "外界有很多反对我爱你的声音...... 87\n",
      "外界有很多反对我爱你的声音...... 88\n",
      "外界有很多反对我爱你的声音...... 89\n",
      "外界有很多反对我爱你的声音...... 90\n",
      "外界有很多反对我爱你的声音...... 91\n",
      "外界有很多反对我爱你的声音...... 92\n",
      "外界有很多反对我爱你的声音...... 93\n",
      "外界有很多反对我爱你的声音...... 94\n",
      "外界有很多反对我爱你的声音...... 95\n",
      "外界有很多反对我爱你的声音...... 96\n",
      "外界有很多反对我爱你的声音...... 97\n",
      "外界有很多反对我爱你的声音...... 98\n",
      "外界有很多反对我爱你的声音...... 99\n"
     ]
    }
   ],
   "source": [
    "# 死循环\n",
    "count = 0\n",
    "while True:\n",
    "    print(\"外界有很多反对我爱你的声音......\",count)\n",
    "    count = count + 1 \n",
    "    if count == 100:\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c0d88ca2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hide_card········\n",
      "猜一猜（0-100）:45\n"
     ]
    }
   ],
   "source": [
    "## 猜数字 小游戏\n",
    "# 1.hide_card;0-100,大了，小了\n",
    "# 2.guess_digit;50\n",
    "import getpass\n",
    "count = 0\n",
    "hide_card = int(getpass.getpass(\"hide_card\"))\n",
    "\n",
    "while True:\n",
    "    \n",
    "    guess_digit = int(input(\"猜一猜（0-100）:\"))\n",
    "\n",
    "# 对比：\n",
    "if hide_card == guess_digit:\n",
    "    print(\"66666666\")\n",
    "elif guess_digit>hide_card:\n",
    "    print(\"往小的去猜！！！！1\")\n",
    "else:\n",
    "    print(\"往大的猜！！！！1\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "990d3b97",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bfd22a79",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "75e2b9cf",
   "metadata": {},
   "source": [
    "# 课后练习\n",
    "> 1.关于列表的切片和方法的使用\n",
    "> >> p67 练习\n",
    ">\n",
    "> >> p81 练习\n",
    "> 2. p89 列表，我们已经知道什么（列表总结）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0103e70c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
